<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%><%@ page session="false"%>
<!DOCTYPE html>
<html lang="es-ES">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="_csrf" content="${_csrf.token}" />
        <meta name="_csrf_header" content="${_csrf.headerName}" />
        <jsp:include page="libs.jsp" flush="true" />
    </head>
    <body class="home blog">
        <jsp:include page="header.jsp" flush="true" />

        <div id="box_breadcrumb" class="clearfix">
            <div class="container">		
                Acceso a recursos internos
            </div>
        </div>

        <div id="box_content">
            <div class="container">
                <!--<div class="col span_16"> -->
                <div class="login_container">
                    <div class="login_header">
                        <div class="login_header_title">
                            <h2 class="texto Titulo">Ingresar</h2>
                        </div>
                    </div>
                    <div class="login_body">
                        <form id="login_form" action="j_spring_security_check" method="post">
                            <div id="loginform">
                                <div class="form_row">
                                    <label for="email" class="login_form_label">Usuario:</label><input type="email" class="inputtext" id="email" name="email"
                                                                                                       value="">
                                </div>
                                <div class="form_row">
                                    <label for="pass" class="login_form_label">Clave:</label><input type="password" name="pass" id="pass" class="inputtext">
                                </div>
                                <div id="buttons" class="form_row">
                                    <label class="login_form_label"></label>
                                    <div id="login_button_inline">
                                        <input class="boton" value="Iniciar sesión" type=submit id="login_button">
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <br/>

        <!-- <jsp:include page="plugin_fotos.jsp" flush="true" /> -->
        <jsp:include page="footer.jsp" flush="true" />
        <script type="text/javascript" >
            $(document).ready(function () {
                $("#login_form").submit(function (e) {
                    e.preventDefault();
                    var url = $(this).attr('action');
                    var data = $(this).serializeArray();
                    $.ajax({
                        url: url,
                        data: data,
                        type: "POST",
                        beforeSend: function (xhr) {
                            //ajaxLoader('block');
                        },
                        success: function (response, status, xhr) {
                            //ajaxLoader('none');
                            var status = xhr.getResponseHeader('StatusLogin');
                            var reason = xhr.getResponseHeader('Reason');
                            if (status == 'ok') {
                                window.location.href=document.location.origin+"/MinamWeb/administrador/principal";
                            } else {
                                alertify.error(reason);
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            console.log("ERROR");
                        }
                    });
                    return false;
                });
            });
        </script>
    </body>
</html>